        <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
        <script>
            function success(position) {
   
                var coords = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);

                var lat = position.coords.latitude;
                var longitude = position.coords.longitude;
             document.getElementById('lat').value = lat;
             document.getElementById('long').value = longitude;

            }

            if (navigator.geolocation) {
                navigator.geolocation.getCurrentPosition(success);
            } else {
                error('Geo Location is not supported');
            }
        </script>
<?php
if (isset($_POST['cmbLista'])) {
    $codigo = $_POST['cmbLista'];
    $cliente = new Clientes();
    $cliente->Carrega($codigo);
}
?>
<form method="post" action="controller/acoes_visita.php" enctype="multipart/form-data">
    <input type="hidden" name="hdCodCliente" id="hdCodCliente" value="<?php
    if (isset($_POST['cmbLista'])) {
        $styleChekin = "";
        echo $cliente->getCodigo();
        
    }else{
        $styleChekin = "disabled=\"disabled\"";
    }
    ?>" />
    <div style="width: 400px; float: left">
        <table class="tabela">
            <tr>
                <td style="width:30px;" class="titulo">Nome<span class="campoRequerido">*</span>:</td>
                <td colspan="2"><input type="text" name="txtNomeCliente" id="txtNomeCliente" placeholder="Nome do Cliente" class="campo" value="<?php
                    if (isset($_POST['cmbLista'])) {
                        echo $cliente->getNome();
                    }
                    ?>" readonly="readonly" onclick="document.getElementById('btBuscar').click()" />

                    <input type="button" name="btBuscar" id="btBuscar" onclick="carregaBusca('DivPesquisaCliente', 'ajax/form_busca.php');" />
                </td>
            </tr>
            <tr>
                <td class="titulo">Data</td>
                <td><input type="text" name="txtDataVisita" id="txtDataVisita" class="campo" placeholder="Data" /></td>
            </tr>
            <tr>
                <td class="titulo" colspan="2" >Foto</td>
            </tr>
            <tr><td colspan="2">
            <div id="Foto">
                <input type="hidden" id="cont_file" value="0"/>
                <input type="file" style="color:white;" name="foto[]" id="foto0" /><input type="button" id="addFoto" name="addFoto" value="+"/>
            </div>    
                </td></tr>
            <tr>
                <td class="titulo">Arquivo:</td>
            </tr>
            <tr><td colspan="2">
            <div id="uploadFile">
                <input type="hidden" id="contFile" value="0"/>
                <input type="file" style="color:white;" name="file[]" id="foto0" /><input type="button" id="addFile" name="addFile" value="+"/>
            </div>    
                </td></tr>
            <tr>
                <td class="titulo" colspan="2">Descri&ccedil;&atilde;o:</td>
            </tr>
            <tr>
                <td colspan="2">
                    <textarea name="txtDescricao" id="txtDescricao" style="width: 350px; height: 150px;" placeholder="Descri&ccedil;&atilde;o da visita" class="campo"></textarea>
                </td>
            </tr>
            <tr>
                <td >
                    <input type="hidden" name="lat" id="lat"/>
                    <input type="hidden" name="long" id="long"/>            
                    <input type="button" <?php echo $styleChekin; ?>  id="checkin" name="checkin" value="CHECK-IN" />
                </td>
                <td><div id="preload" style="display:none;"><img src="img/488.gif" /></div></td>               
            </tr>
            <tr>
                <td>
                    <input type="submit" name="btSalvar" id="btSalvar" class="botao" value="Salvar" onclick="return ValidaFormulario('txtNomeCliente|txtDataVisita','Preencha os campos requeridos');" />
                </td>
            </tr>
        </table>
    </div>
    <?php
    if (isset($_POST['cmbLista'])) {
        $codusuarioLogado = $_SESSION['codigo_logado'];
        $listaVisitas = Visitas::lista_visitas(" WHERE codcliente = '$codigo' AND codusuario = '$codusuarioLogado' ORDER BY codigo DESC");
        if ($listaVisitas) {
            ?>
            <div style="width: 540px; height: 300px; float: left; border-left: 1px solid whitesmoke; overflow: auto">
                <table width="100%" ceellpadding="0" cellspacing="1">
                    <tr style="background-color: #FFF">
                        <td colspan="4" style="border-bottom: 1px solid #000"><strong>Hist&oacute;rico do Cliente</strong></td>
                    </tr>
                    <tr style="background-color: #CCC">
                        <td align="center"><strong>Data</strong></td>
                        <td align="center"><strong>Volume</strong></td>
                        <td align="center"><strong>Telefone</strong></td>
                        <td align="center"><strong>Descri&ccedil;&atilde;o</strong></td>
                    </tr>
                    <?php
                    foreach ($listaVisitas as $visita) {
                        $aux = explode(" ", $visita->getDatahora());
                        $data = $aux[0];
                        $hora = $aux[1];
                        $dadosCliente = new Clientes($visita->getCodcliente());
                        ?>
                        <tr style="background-color:#FFF;">
                            <td style="border-bottom:1px solid whitesmoke;border-right:1px solid whitesmoke; " align="left"><?php echo Util::dataToBR($data) . " " . $hora; ?></td>
                            <td style="border-bottom:1px solid whitesmoke;border-right:1px solid whitesmoke;" align="left"><?php echo $dadosCliente->getVolume(); ?></td>
                            <td style="border-bottom:1px solid whitesmoke;border-right:1px solid whitesmoke;" align="left"><?php echo $dadosCliente->getTelefone(); ?></td>
                            <td style="border-bottom:1px solid whitesmoke;" align="left"><?php echo $visita->getDescricao(); ?></td>
                        </tr>
                        <?php
                    }
                    ?>
                </table>
            </div>
            <?php
        }
    }
    ?>
</form>
<script type="text/javascript">
    function removeFotoUp(a){
        var	a = a;
        //$('br:last').remove();
        $("#delFoto"+a).remove();
        $("#foto"+a).remove();
    }
    function removeUpFile(a){
        var	a = a;
        $("#del"+a).remove();
        $("#file"+a).remove();
    }


</script>
